﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SetfNovelLib;
using SetfNovelLib.Entities;

namespace StefNovel
{
    public partial class ReadBook : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["book"] == null)
                Session["book"] = TestStef.GenerateBook();
            BookInfo b = Session["book"] as BookInfo;
            Literal content = new Literal();
            content.Text += "<ul>";
            foreach (SectionType s in new SectionType[] { SectionType.AvantPropos, SectionType.Remerciements, SectionType.Dedicace, SectionType.Prologue, SectionType.Introduction })
                if (b.SpecialSections.ContainsKey(s))
                    content.Text += "<li><a href=\"ReadChapter.aspx?s=" + (int)s + "\"><b>" + s.ToString() + ":</b> " + b.SpecialSections[s].Title + "</a></li>";
            content.Text += "</ul><ul>";
            foreach (int i in b.ContentChapters.Keys)
                content.Text += "<li><a href=\"ReadChapter.aspx?s=" + (int)SectionType.Developpement + "&c=" + i + "\"><b>Chapitre " + i + ":</b> " + b.ContentChapters[i].Title + "</a></li>";
            content.Text += "</ul>";
            content.Text += "<ul>";
            foreach (SectionType s in new SectionType[] { SectionType.Conclusion, SectionType.Epilogue, SectionType.APropos })
                if (b.SpecialSections.ContainsKey(s))
                    content.Text += "<li><a href=\"ReadChapter.aspx?s=" + (int)s + "\"><b>" + s.ToString() + ":</b> " + b.SpecialSections[s].Title + "</a></li>";

            content.Text += "</ul><ul>";
            pnlSections.Controls.Add(content);
        }
    }
}